package com.webinsky.article.persist.dao;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ArticleRelateVideoMapperProvider {
	
	private static final String SELECT_TEMPLATE = "select id, article_id, relate_video_id, sort, del, create_at, update_at, language from article_relate_video";
	
	@SuppressWarnings("unchecked")
	public String selectByArticleIds(Map<String, Object> params){
		List<Integer> articleIds = (List<Integer>)params.get("articleIds");
		String conditions = " where del = 0 ";
		if ( articleIds != null ){
			List<String> strIds = articleIds.stream().map(e -> e.toString()).collect(Collectors.toList());
			conditions = conditions + "and article_id in (" + String.join(",", strIds) + ")";
		}
		return SELECT_TEMPLATE + conditions;
	}
}
